package acttest.controller;

import java.util.Date;
import java.util.List;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import acttest.dao.BaseDao;
import acttest.entity.User;
import service.UserService;

@Controller
@RequestMapping("/userController")
public class UserController {
	@Autowired
	UserService userService;

	@RequestMapping("/save")
	@ResponseBody
	public boolean save(String username,String password) {
		User user = new User(username,password,new Date(),"this is a remark...");
		try {
			userService.addUser(user);
			return true;
		}catch(Exception e) {
			e.printStackTrace();
			return false;
		}
	}
	
	@RequestMapping("/queryUserList")
	@ResponseBody
	public List<User> queryUserList(){
		return userService.queryUser("select * from user");
	}
	
}
